package edu.drexel.cs.eVoter.VoterClient;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;

public class VoterClient 
{
	private static JFrame 			mainFrame;
	private JTabbedPane           jtp;
	private VoteRequestPanel      votePanel;
	private CandidateResultsPanel candidatePanel;
	private StateResultsPanel     statePanel;
	private NationalResultsPanel  nationalPanel;
	private DebugDataPanel        debugPanel;
	private ServerInterface       myServerInterface;
	
	public VoterClient()
	{
		mainFrame = new JFrame( "CS 647 Voter Client" );
		
		myServerInterface = new ServerInterface();
		
		new Thread( myServerInterface ).start();
		
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mainFrame.setSize( 500, 600 );
		jtp = new JTabbedPane();

		votePanel = new VoteRequestPanel( myServerInterface );
		jtp.addTab("Vote", votePanel );
		candidatePanel = new CandidateResultsPanel( myServerInterface );
		jtp.addTab("Candidate Results", candidatePanel );
		statePanel = new StateResultsPanel( myServerInterface );
		jtp.addTab("State Results:", statePanel );
		nationalPanel = new NationalResultsPanel( myServerInterface );
		jtp.addTab("National Results:", nationalPanel );
		debugPanel = new DebugDataPanel( myServerInterface );
		jtp.addTab("Debug", debugPanel );
		
		mainFrame.getContentPane().add( jtp );
		
		mainFrame.setVisible(true);
	}
	
	public static void displayMessage(String message, String title, int messageType)
	{
		JOptionPane.showMessageDialog(mainFrame, message,
		        title, messageType);
	}
	
	public static void main(String[] args) 
	{
		new VoterClient();
	}

}
